package com.lhy.framework.beans.factory.support;

import com.lhy.framework.beans.factory.factory.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName DefaultSingletonBeanRegistry
 * @Description
 * @Author lihaiyang
 * @Date 2022/9/8 22:24
 * @Version 1.0
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    private Map<String, Object> singletonObjects = new HashMap<>();

    /**
     * 获取单例对象
     * @param beanName
     * @return
     */
    @Override
    public Object getSingleton(String beanName) {
        return singletonObjects.get(beanName);
    }

    /**
     * 添加单例bean对象
     * @param beanName
     * @param object
     */
    public void addSingleton(String beanName, Object object) {
        singletonObjects.put(beanName, object);
    }
}
